package com.uenpay.im.ui.base;

import com.uenpay.im.IMApplication;
import com.uenpay.im.R;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;


/**
 * @author SL
 * @created 2016-2-29 下午16:03:08
 * @copyRight http://www.qiyunxin.com
 * @function TODO
 */
public abstract class BaseActivity extends AppCompatActivity {

	protected View loading;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		IMApplication.getInstance().addActivity(this);
	}

	protected void backListener() {
		findViewById(R.id.back_layout).setOnClickListener(
				new OnClickListener() {

					@Override
					public void onClick(View v) {
						finish();
					}
				});
	}

	/**
	 * 初始化View
	 */
	protected abstract void initView();

	/**
	 * 初始化事件
	 */
	protected abstract void initListener();

	@Override
	public void onBackPressed() {
		super.onBackPressed();
		finish();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		IMApplication.getInstance().removeActivity(this);
	}

}
